﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Linq.Expressions;

namespace Pavilion.DesignerTool
{
    public abstract class NotifyPropertyChangedBase : INotifyPropertyChanged
    {
        public virtual event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged<T>(Expression<Func<T>> property)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs((property.Body as MemberExpression).Member.Name));
        }

        static public void OnPropertyChanged<T>(PropertyChangedEventHandler propertyChangedEvent, object sender, Expression<Func<T>> property)
        {
            if (propertyChangedEvent != null)
                propertyChangedEvent(sender, new PropertyChangedEventArgs((property.Body as MemberExpression).Member.Name));
        }
    }
}
